import { Options, Vue } from 'vue-class-component'
import navigator from '@/components/common/navigator.vue'
import router from '@/router'
import store from '@/store'

interface iBasicInformation {
  nickname: string
  realName: string
  email: string
  mobile: string
  gender: string
  birthday: Date
}
@Options({
  components: {
    navigator
  }
})

export default class basicInformation extends Vue {
  userId = '0'
  basicInformationInfo: iBasicInformation = {
    nickname: '',
    realName: '',
    email: '',
    mobile: '',
    gender: '',
    birthday: new Date()
  }

  mounted () {
    if (store.state.u !== null) {
      this.userId = store.state.u.userId
      store.dispatch('getBasicUserInfo', this.userId)
        .then(response => {
          this.basicInformationInfo = response.data.data
          console.log(this.basicInformationInfo)
        }).catch(() => {
          console.log('connect failed')
        })
    }
  }

  edit (): void {
    router.push({
      path: '/set'
    })
  }
}
